﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using SAC.Elink;
using SAC.Power;
using SAC.sqlHelper;
namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //Stopwatch watch = new Stopwatch();
            //watch.Start();


            ////for (int t = 1; t <= 100; t++)
            ////{
            //String szPoint = "WHSIS.CALC.ZBTJH001"; //String.Format("{0}.{1}{2}", "HESHAN.TESTUNIV", 1, t.ToString().PadLeft(7, '0'));
            //double dValue = 0;
            //int nRet = eDnaApiNet.RealTime.LowSpeed.DNAGetRTValue(szPoint, ref dValue);
            //Console.WriteLine("PointName " + szPoint + "  value :" + dValue);
            //szPoint = "WHSIS.CALC.ZBTJH007"; //String.Format("{0}.{1}{2}", "HESHAN.TESTUNIV", 1, t.ToString().PadLeft(7, '0'));
            //dValue = 0;
            //nRet = eDnaApiNet.RealTime.LowSpeed.DNAGetRTValue(szPoint, ref dValue);
            //Elink edna = new Elink();

            //double dValue = edna.GetRTValue("WHSIS.CALC.ZBTJH007");

            //Console.WriteLine("PointName WHSIS.CALC.ZBTJH007  value :" + edna.GetStrRTValue("WHSIS.CALC.ZBTJH007"));
            // }

            //String szPoint = String.Format("{0}.{1}{2}", "HESHAN.TESTUNIV", 1, t.ToString().PadLeft(7, '0'));
            //double pdValue = -1;
            //DateTime dateTime;
            //String status;
            //int nRet = eDnaApiNet.RealTime.LowSpeed.DNAGetRTShort("WHSIS.CALC.ZBTJH007", ref pdValue, out dateTime, out status);
            //Console.WriteLine("PointName : " + "WHSIS.CALC.ZBTJH007");
            //Console.WriteLine("return code :" + nRet);
            //Console.WriteLine("return value :" + pdValue);
            //Console.WriteLine("return time :" + dateTime);
            //Console.WriteLine("return status :" + status);


            //int nRet = eDnaApiNet.Configuration.Point.DnaSelectPoint(out point);
            //Console.WriteLine("szPoint : " + point);

            //eDnaApiNet.History.LowSpeed.Reading.d
            //ELink.declare eDNA = new ELink.declare();

            //string time1 = "2011-09-27 00;00:00";
            //object value1 = 0;
            //string ip = "172.16.29.150";
            //string port = "8001";
            //int j = eDNA.ConnectToServer(ref ip, ref port);

            //int i = eDNA.GetHistValue(ref point, ref time1, ref value1);

            //Console.WriteLine("return code" + i + "Elink Vlaue :" + value1);

            //8609564
            //8649126
            //DateTime st = DateTime.Parse("2011-10-25 23:59:59");
            //DateTime et = DateTime.Parse("2011-10-25 23:59:59");

            //uint key = 1;

            //double value = -1;

            //DateTime utcTime;
            //string status;
            //DateTime time = DateTime.Now;

            //int nRet = eDnaApiNet.History.LowSpeed.Reading.DnaGetHistSnap(point, st, et, new TimeSpan(0, 0, 0, 1, 0), out key);

            //TimeSpan span = DateTime.Now - time;

            //Console.WriteLine("耗时 : " + span.TotalMilliseconds);

            //if (nRet == 0)
            //{
            //    Console.WriteLine("coder : " + nRet);

            //    while (0 == eDnaApiNet.History.LowSpeed.Reading.DnaGetNextHist(key, ref value, out utcTime, out status))
            //    {
            //        Console.WriteLine("time : " + utcTime + " value:" + value + " status :" + status);
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("error :" + nRet);
            //}

            //watch.Stop();
            //Console.WriteLine("耗时 : " + watch.ElapsedMilliseconds);

            //if (Convert.ToDateTime("2011-10-01") > DateTime.Now) { Console.WriteLine("adsfasd"); }

            //Console.WriteLine("asdfadsf");

            //*************取历史之************//
            //int ret = 0;

            //string point = "WHSIS.UNIV.TEST1"; //"WHSIS.UNIV.ZBTJY285";// "WHSIS.U1APSH.U1A03815";// "";// 

            //Elink ek = new Elink();

            //object val = 112;

            //string time = "2012-03-29 11:59:59";

            //int l = ek.SetCurValue(ref point, ref val);

            //int l = ek.SetHisValue(ref point, ref time, ref val);

            //string strRT = ek.GetStrRTValue(point);
            //Console.WriteLine("实时值" + strRT);

            //double val1 = 0;
            //ek.GetHisValue(point, "2012-03-29 12:59:59", ref ret, ref val1);
            //Console.WriteLine("历史值" + val1.ToString());

            ////ELink.declare ek1 = new ELink.declare();
            //string time = "2012-03-29 13:59:59";
            //object value = null;
            //int j = ek1.GetHistRawValue(ref point, ref time, ref value);

            //Console.WriteLine("TEST");

            //string[] a = { "1 ", "2 ", "3 ", "4 ", "5 " };
            //string[] b = { "A ", "B ", "C ", "D ", "E " };

            //string[] c = new string[a.Length + b.Length];

            //a.CopyTo(c, 0);
            //b.CopyTo(c, a.Length);


            //foreach (string v in c)
            //{
            //    Console.Write(v);
            //}

            //Console.Read();

            //SAC.Power.PowerCale pc = new PowerCale();
            //string id = "mmj2a";
            //double val = 0;
            //DateTime dt = DateTime.Now.AddDays(-1);

            //string bm = "";
            //double b = double.Parse(pc.GetPower(val, id, dt.ToString("yyyy-MM-dd 0:00:00"), dt.AddDays(+1).ToString("yyyy-MM-dd 0:00:00"), bm).ToString());
            //string errMsg = "";

            //object obj1;
            //object obj2;

            //string sql1;
            //string sql2;

            //double gwdl;

            //sql1 = " SELECT SUM(1-运行小时) AS Expr1 FROM 机组运行小时数据表 WHERE (设备类型='发电机') AND (机组 = 1) AND (日期 >= '2010-10-01 0:00:00') AND (日期 <'2010-10-01 0:00:00')";

            //obj1 = DBsql.RunSingle(sql1, out errMsg);

            //sql2 = " SELECT SUM(1-运行小时) AS Expr1 FROM 机组运行小时数据表 WHERE (设备类型='发电机') AND (机组 = 2) AND (日期 >= '2010-10-01 0:00:00') AND (日期 <'2010-10-01 0:00:00')";

            //obj2 = DBsql.RunSingle(sql2, out errMsg);

            //string fm = obj1.ToString() + "+" + obj2.ToString();


            //string s = SAC.Helper.StrHelper.Cale(fm);

            //PubOp.OperateIniFile of = new PubOp.OperateIniFile();

            //bool falg = PubOp.OperateIniFile.WriteIniData("1", "key2", "22", "c:/cs.ini");

            //string tt = PubOp.OperateIniFile.ReadIniData("test", "key1", " ", "c:/cs.ini");

            //            //获取当前进程的完整路径，包含文件名(进程名)。
            //string str = this.GetType().Assembly.Location;
            //result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

            ////获取新的 Process 组件并将其与当前活动的进程关联的主模块的完整路径，包含文件名(进程名)。
            //string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            //result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

            ////获取和设置当前目录（即该进程从中启动的目录）的完全限定路径。
            //string str = System.Environment.CurrentDirectory;
            //result: X:\xxx\xxx (.exe文件所在的目录)

            ////获取当前 Thread 的当前应用程序域的基目录，它由程序集冲突解决程序用来探测程序集。
            //string str = System.AppDomain.CurrentDomain.BaseDirectory;
            //result: X:\xxx\xxx\ (.exe文件所在的目录+"\")

            ////获取和设置包含该应用程序的目录的名称。
            //string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            //result: X:\xxx\xxx\ (.exe文件所在的目录+"\")

            ////获取启动了应用程序的可执行文件的路径，不包括可执行文件的名称。
            //string str = System.Windows.Forms.Application.StartupPath;
            //result: X:\xxx\xxx (.exe文件所在的目录)

            ////获取启动了应用程序的可执行文件的路径，包括可执行文件的名称。
            //string str = System.Windows.Forms.Application.ExecutablePath;
            //result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)

            ////获取应用程序的当前工作目录(不可靠)。
            //string str = System.IO.Directory.GetCurrentDirectory();
            //result: X:\xxx\xxx (.exe文件所在的目录)

        }

    }
}
